class Notify {
  constructor() {
    this.types = {};
  }
  setNotify(key, fun) {
    if (this.types[key]) {
      this.types[key].push(fun);
    } else {
      this.types[key] = [fun];
    }
  }
  send(key, data) {
    if (this.types[key]) {
      this.types[key].forEach(item => {
        item(data);
      });
    }
  }
  clear(key) {
    delete this.types[key]
  }
}

let notify = new Notify();

export default notify;
